DIG(1) | BIND9 | DIG(1) |
NAME¶
dig - DNS lookup utility
SYNOPSIS¶
dig [@server] [-b address] [-c class] [-f filename] [-k filename] [-m] [-p port#] [-q name] [-t type] [-v] [-x addr] [-y [hmac:]name:key] [[-4] | [-6]] [name] [type] [class] [queryopt...]
dig [-h]
dig [global-queryopt...] [query...]
DESCRIPTION¶
dig is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use dig to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. Other lookup tools tend to have less functionality than dig.
Although dig is normally used with command-line arguments, it also has a batch mode of operation for reading lookup requests from a file. A brief summary of its command-line arguments and options is printed when the -h option is given. Unlike earlier versions, the BIND 9 implementation of dig allows multiple lookups to be issued from the command line.
Unless it is told to query a specific name server, dig will try each of the servers listed in /etc/resolv.conf. If no usable server addresses are found, dig will send the query to the local host.
When no command line arguments or options are given, dig will perform an NS query for "." (the root).
It is possible to set per-user defaults for dig via ${HOME}/.digrc. This file is read and any options in it are applied before the command line arguments. The -r option disables this feature, for scripts that need predictable behaviour.
The IN and CH class names overlap with the IN and CH top level domain names. Either use the -t and -c options to specify the type and class, use the -q the specify the domain name, or use "IN." and "CH." when looking up these top level domains.
SIMPLE USAGE¶
A typical invocation of dig looks like:
dig @server name type
where:
server
If no server argument is provided, dig consults /etc/resolv.conf; if an address is found there, it queries the name server at that address. If either of the -4 or -6 options are in use, then only addresses for the corresponding transport will be tried. If no usable addresses are found, dig will send the query to the local host. The reply from the name server that responds is displayed.
name
type
OPTIONS¶
-4
-6
-b address[#port]
-c class
-f file
-i
-k keyfile
-m
-p port
-q name
-r
-t type
All resource record types can be expressed as "TYPEnn", where "nn" is the number of the type. If the resource record type is not supported in BIND 9, the result will be displayed as described in RFC 3597.
-u
-v
-x addr
-y [hmac:]keyname:secret
NOTE: You should use the -k option and avoid the -y option, because with -y the shared secret is supplied as a command line argument in clear text. This may be visible in the output from ps(1) or in a history file maintained by the user's shell.
QUERY OPTIONS¶
dig provides a number of query options which affect the way in which lookups are made and the results displayed. Some of these set or reset flag bits in the query header, some determine which sections of the answer get printed, and others determine the timeout and retry strategies.
Each query option is identified by a keyword preceded by a plus sign (+). Some keywords set or reset an option. These may be preceded by the string no to negate the meaning of that keyword. Other keywords assign values to options like the timeout interval. They have the form +keyword=value. Keywords may be abbreviated, provided the abbreviation is unambiguous; for example, +cd is equivalent to +cdflag. The query options are:
+[no]aaflag
+[no]aaonly
+[no]additional
+[no]adflag
+[no]all
+[no]answer
+[no]authority
+[no]badcookie
+[no]besteffort
+bufsize=B
+[no]cdflag
+[no]class
+[no]cmd
+[no]comments
Other types of comments in the output are not affected by this option, but can be controlled using other command line switches. These include +[no]cmd, +[no]question, +[no]stats, and +[no]rrcomments.
+[no]cookie[=####]
+cookie is also set when +trace is set to better emulate the default queries from a nameserver.
+[no]crypto
+[no]defname
+[no]dnssec
+domain=somename
+dscp=value
+[no]edns[=#]
+[no]ednsflags[=#]
+[no]ednsnegotiation
+[no]ednsopt[=code[:value]]
+[no]expire
+[no]fail
+[no]header-only
+[no]identify
+[no]idnin
The default is to process IDN input when standard output is a tty. The IDN processing on input is disabled when dig output is redirected to files, pipes, and other non-tty file descriptors.
+[no]idnout
The default is to process puny code on output when standard output is a tty. The puny code processing on output is disabled when dig output is redirected to files, pipes, and other non-tty file descriptors.
+[no]ignore
+[no]keepopen
+[no]mapped
+[no]multiline
+ndots=D
+[no]nsid
+[no]nssearch
+[no]onesoa
+[no]opcode=value
+[no]qr
+[no]question
+[no]rdflag
+[no]recurse
+retry=T
+[no]rrcomments
+[no]search
'ndots' from resolv.conf (default 1) which may be overridden by +ndots determines if the name will be treated as relative or not and hence whether a search is eventually performed or not.
+[no]short
+[no]showsearch
+[no]sigchase
+split=W
+[no]stats
+[no]subnet=addr[/prefix-length]
dig +subnet=0.0.0.0/0, or simply dig +subnet=0 for short, sends an EDNS CLIENT-SUBNET option with an empty address and a source prefix-length of zero, which signals a resolver that the client's address information must not be used when resolving this query.
+[no]tcp
+timeout=T
+[no]topdown
+[no]trace
If @server is also specified, it affects only the initial query for the root zone name servers.
+dnssec is also set when +trace is set to better emulate the default queries from a nameserver.
+tries=T
+trusted-key=####
If not specified, dig will look for /etc/trusted-key.key then trusted-key.key in the current directory.
Requires dig be compiled with -DDIG_SIGCHASE. This feature is deprecated. Use delv instead.
+[no]ttlid
+[no]ttlunits
+[no]unknownformat
+[no]vc
+[no]zflag
MULTIPLE QUERIES¶
The BIND 9 implementation of dig supports specifying multiple queries on the command line (in addition to supporting the -f batch file option). Each of those queries can be supplied with its own set of flags, options and query options.
In this case, each query argument represent an individual query in the command-line syntax described above. Each consists of any of the standard options and flags, the name to be looked up, an optional query type and class and any query options that should be applied to that query.
A global set of query options, which should be applied to all queries, can also be supplied. These global query options must precede the first tuple of name, class, type, options, flags, and query options supplied on the command line. Any global query options (except the +[no]cmd option) can be overridden by a query-specific set of query options. For example:
dig +qr www.isc.org any -x 127.0.0.1 isc.org ns +noqr
shows how dig could be used from the command line to make three lookups: an ANY query for www.isc.org, a reverse lookup of 127.0.0.1 and a query for the NS records of isc.org. A global query option of +qr is applied, so that dig shows the initial query it made for each lookup. The final query has a local query option of +noqr which means that dig will not print the initial query when it looks up the NS records for isc.org.
IDN SUPPORT¶
If dig has been built with IDN (internationalized domain name) support, it can accept and display non-ASCII domain names. dig appropriately converts character encoding of domain name before sending a request to DNS server or displaying a reply from the server. If you'd like to turn off the IDN support for some reason, use parameters +noidnin and +noidnout or define the IDN_DISABLE environment variable.
RETURN CODES¶
Dig return codes are:
FILES¶
/etc/resolv.conf
${HOME}/.digrc
SEE ALSO¶
delv(1), host(1), named(8), dnssec-keygen(8), RFC 1035.
BUGS¶
There are probably too many query options.
AUTHOR¶
Internet Systems Consortium, Inc.
COPYRIGHT¶
Copyright © 2000-2011, 2013-2021 Internet Systems Consortium, Inc. ("ISC")
2014-02-19 | ISC |